package com.jielin.handling.controller.information;

import com.alibaba.fastjson.JSONObject;
import com.jielin.handling.Annotation.MyPower;
import com.jielin.handling.bean.AppResult;
import com.jielin.handling.entity.information.Information;
import com.jielin.handling.service.information.InformationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wangjienice on 2019/3/20.
 */
@CrossOrigin
@RestController
@RequestMapping("/information/")
@Slf4j
//@MyPower(name = "嫌疑人信息采集模块", url = "/information")
public class InformationController {
    @Autowired
    InformationService InformationService;

    /**
     * 信息采集添加
     */
//    @MyPower(name = "信息采集添加", url = "/addInformation")
    @RequestMapping("addInformation")
    public AppResult addInformation(@RequestBody  Information information){
        AppResult appResult = new AppResult();
        JSONObject date = new JSONObject();
        log.info("information:{}", JSONObject.toJSONString(information));
        int value = InformationService.addInformation(information);
        if (value > 0) {
            date.put("Value", 1);
            appResult.setCode(200);
            appResult.setMsg("添加信息采集成功!");
            appResult.setData(date);
        } else {
            date.put("value", 0);
            appResult.setCode(-1);
            appResult.setMsg("添加信息采集失败!");
            appResult.setData(date);
        }
        return appResult;
    }
}




